package com.max.api;

import com.max.base.BaseController;
import com.max.common.R;
import com.max.dto.ReservationDTO;
import com.max.service.IRoomReservationService;
import com.max.vo.MineReservationListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


@Api(tags = "会议室鉴权接口")
@RequestMapping("/secret/room")
@RestController
@Validated
public class MettingRoomSecretApi extends BaseController {

    @Autowired
    private IRoomReservationService roomReservationService;


    @ApiOperation("会议室预约")
    @RequestMapping("/reservation")
    public R<?> roomReservation(@Valid @RequestBody ReservationDTO dto) {
        return R.result(roomReservationService.roomReservation(dto));
    }

    @ApiOperation("取消会议室预约")
    @RequestMapping(value = "/cancelReservation/{reservationId}", method = RequestMethod.POST)
    public R<?> cancelReservation(@PathVariable("reservationId") Long reservationId) {
        return R.result(roomReservationService.cancelReservation(reservationId));
    }


    @ApiImplicitParams({
            @ApiImplicitParam(value = "当前页", name = "pageNum", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(value = "每页数量", name = "pageSize", dataType = "Integer", paramType = "query")
    })
    @ApiOperation("查询我的预约列表")
    @RequestMapping(value = "/mineReservation", method = RequestMethod.GET)
    public R<List<MineReservationListVO>> selectMineReservationList() {
        startPage();
        return R.ok(roomReservationService.mineReservationList());
    }



}
